package com.jlb.jobhandler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.log.XxlJobLogger;

import java.util.HashMap;
import java.util.Map;

public class Demo {

    public static void main(String[] args) {

        Demo demo = new Demo();
        demo.MapTest();

    }

    public void MapTest() {
        Map<String, String> map = new HashMap<>();
        map.put("111", "111");
        map.put("222", "222");
        map.put("333", "333");
        map.put("444", "444");
        map.put("555", "555");

        // 遍历 Map
        // 第一种：普遍使用，二次取值
        for (String key : map.keySet()) {
            System.out.println("key= " + key + " and value= " + map.get(key));
        }
        // Map的clear()方法为清空Map
        map.clear();
        // 第三种：推荐，尤其是容量大时
        System.out.println("通过Map.entrySet遍历key和value");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
        }
    }


    /**
     * success
     */
    public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null);


    public ReturnT<String> execute(String param) throws Exception {
        String result = "";
        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", "吴彦祖");
//        result = HttpTool.httpCall("http://localhost:8762/testUnit/synDataFromDown", paraMap, "POST");
//        XxlJobLogger.log("-------------------调度测试结束------------------ " + result);
//
//        //传递参数变为jsonArray测试
//        paraMap.clear();
//        paraMap.put("jsonArray", result);
//        result = HttpTool.httpCall("http://localhost:8763/userinfo/getByJsonArrayPost", paraMap, "POST");
//        XxlJobLogger.log("-------------------参数为jsonArray调度测试结束------------------ " + result);

        // 测试PPS-factory接口
        paraMap.clear();
//        result = HttpTool.INSTANCE.post("http://192.168.1.182:8080/testUnit/uptowardsForJob", paraMap);
        XxlJobLogger.log("-------------------调用PPS-factory测试结束------------------ " + result);
        return SUCCESS;
    }


}
